<template>
<div>
    <Form :model="formCustom" :label-width="80">
        <FormItem label="订单计时(小时)" prop="task_time">
            <Input type="text" v-model="formCustom.task_time" value="" ></Input>
        </FormItem>
        <FormItem label="基础收藏数" prop="base_collection">
            <Input type="text" v-model="formCustom.base_collection" value="" ></Input>
        </FormItem>
        <FormItem label="默认学校" prop="w_school">
            <Input type="text" v-model="formCustom.w_school" value="" ></Input>
        </FormItem>
        <FormItem label="最大凑单堂豆" prop="max_bean">
            <Input type="text" v-model="formCustom.max_bean" value="" width="70%"></Input>
        </FormItem>
        <FormItem label="学生认证奖励堂豆" prop="first_login">
            <Input type="text" v-model="formCustom.certification_beans" value="" width="70%"></Input>
        </FormItem>
        <FormItem label="新人见面礼" prop="first_login">
            <Input type="text" v-model="formCustom.first_login" value="" width="70%"></Input>
        </FormItem>
        <FormItem label="完善个人信息奖励堂豆" prop="phone_beans" >
            <Input type="text" v-model="formCustom.phone_beans" value="" width="70%"></Input>
        </FormItem>
        <FormItem label="首次发布物品奖励堂豆" prop="publish_beans">
            <Input type="text" v-model="formCustom.publish_beans" value="" width="70%"></Input>
        </FormItem>
        <FormItem label="首次送出物品奖励堂豆" prop="sendout_beans">
            <Input type="text" v-model="formCustom.sendout_beans" value="" width="70%"></Input>
        </FormItem>
        <FormItem label="每日登陆奖励堂豆" prop="login_beans">
            <Input type="text" v-model="formCustom.login_beans" value="" width="70%"></Input>
        </FormItem>
        <FormItem label="分享奖励堂豆" prop="share_beans">
            <Input type="text" v-model="formCustom.share_beans" value="" width="70%"></Input>
        </FormItem>
        <FormItem>
            <Button type="primary" @click="handleSubmit('formCustom')">Submit</Button>
        </FormItem>
    </Form>
</div>
</template>
<script>
    import util from '../libs/util';
    export default {
        created() {
            this.$http.get(util.baseURL+"property/propertyList",)
                    .then(
                        (response)=>{
                            if(response.data.data) {
                              this.process_data(response.data.data);
                            } else {
                               this.$Message.error("暂无配置信息！");
                               return;
                            }
                        },
                        (error)=>{
                            console.log(error);
                        }
                );
               
        },
        data () {
            return {
                formCustom: {
                   app_id : '',
                   app_secret:'',
                   base_collection: ''
                },
            }
        },
        methods: {
            process_data(data) {
                
               for (var i=0; i<data.length; i++) {
                   this.formCustom[data[i].k] = data[i].v;
               }
               
            },
            handleSubmit () {
                //console.log(this.formCustom);
                this.$http.post(util.baseURL+"property/updateBeanProperty",this.formCustom,
                    {emulateJSON: true})
                    .then(
                        (response)=>{
                            if(response.data.data) {
                               this.$Message.info("更新成功！");
                            } else {
                               this.$Message.error("更新失败！");
                            }
                        },
                        (error)=>{
                            console.log(error);
                        }
                );
            },
        }
    }
</script>